<template>
  <div>
    <h1>$ref</h1>
    <my-input ref="myInput" />
    <button @click="focus">获取焦点</button>
  </div>
</template>

<script>
import myInput from "./myInput.vue";
export default {
  components: {
    myInput
  },
  methods: {
    focus() {
      this.$refs.myInput.focus();
      this.$refs.myInput.value = "hello";
    }
  }
};
</script>
